# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python


class Recipe(recipe.Recipe):
    name = 'libdv'
    version = '1.0.0'
    stype = SourceType.TARBALL
    url = 'sf://.tar.gz'
    tarball_checksum = 'a305734033a9c25541a59e8dd1c254409953269ea7c710c39e540bd8853389ba'
    licenses = [License.LGPLv2_1Plus]
    autoreconf = True
    patches = ['libdv/0001-Check-properly-for-sched_setscheduler.patch',
               'libdv/0003-Don-t-build-test-programs.patch',
               'libdv/0004-Fix-compilation-on-Android.patch',
               'libdv/0005-Fix-compilation-on-Windows-some-more.patch',
               'libdv/0006-Add-the-pthread-libs-to-pkg-config.patch',
               'libdv/0007-Don-t-require-libsdl-to-be-installed-for-autoreconf.patch',
               'libdv/0012-Build-a-DLL-on-Windows.patch',
               'libdv/0013-Fix-endianess-detection-with-mingw-w64.patch',
               'libdv/0014-libdv-fix-build-of-gasmoff-after-autoreconf.patch']

    files_libs = ['libdv']
    files_devel = ['include/libdv', 'lib/pkgconfig/libdv.pc']

    def prepare(self):
        if self.config.variants.nox11:
            self.configure_options += ' --disable-xv --without-x'
        if self.config.target_platform == Platform.WINDOWS:
            self.configure_options += ' --disable-asm'
            self.append_env('LDFLAGS', '-lpthread')
        elif self.config.target_platform == Platform.DARWIN:
            self.configure_options += ' --disable-asm'
        elif self.config.target_platform == Platform.ANDROID:
            if self.config.target_arch in [Architecture.X86, Architecture.X86_64]:
                self.configure_options += ' --disable-asm'
            self.autoreconf = True
        elif self.config.target_platform == Platform.IOS:
            if self.config.target_arch in [Architecture.X86, Architecture.X86_64]:
                self.configure_options += ' --disable-asm'
